﻿using DataAccessLayer;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BussinessLogicLayer
{
    public class BLL_Question
    {
        public List<QUESTION> Load(QUESTION question)
        {
            var listQuestion = new List<QUESTION>();

            DataTable dt = DAO_Question.Load(question);
            foreach (DataRow item in dt.Rows)
            {
                QUESTION q = new QUESTION();
                q.USER_ID = item["USER_ID"].ToString().Trim();
                q.QUESTION_ID = Convert.ToInt32(item["QUESTION_ID"]);
                q.QUESTION_DESCRIPTION = item["QUESTION_DESCRIPTION"] == DBNull.Value ? "" : item["QUESTION_DESCRIPTION"].ToString().Trim();
                q.QUESTION_LEVEL = item["QUESTION_LEVEL"].ToString().Trim();
                q.QUESTION_TYPE = item["QUESTION_TYPE"].ToString().Trim();
                if (q.QUESTION_LEVEL == "1")
                {
                    q.QUESTION_LEVEL = "Easy";
                }
                else if (q.QUESTION_LEVEL == "2")
                {
                    q.QUESTION_LEVEL = "Medium";
                }
                else if (q.QUESTION_LEVEL == "3")
                {
                    q.QUESTION_LEVEL = "Hard";
                }

                if (q.QUESTION_TYPE == "SINGLE_RESPONSE")
                {
                    q.QUESTION_TYPE = "Single response";
                }
                else if (q.QUESTION_TYPE == "MULTI_RESPONSE")
                {
                    q.QUESTION_TYPE = "Multi response";
                }
                else if (q.QUESTION_TYPE == "FILL_BLANK")
                {
                    q.QUESTION_TYPE = "Fill blank";
                }
                else if (q.QUESTION_TYPE == "ASSOCIATE")
                {
                    q.QUESTION_TYPE = "Associate";
                }
                else if (q.QUESTION_TYPE == "ORDER_ITEMS")
                {
                    q.QUESTION_TYPE = "Order items";
                }

                listQuestion.Add(q);
            }

            return listQuestion;
        }
    }
}
